package com.isoft.controller.sys;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.isoft.anno.SysControllerLogAnnotation;
import com.isoft.bean.OprateType;
import com.isoft.bean.ResponseData;
import com.isoft.bean.SysType;
import com.isoft.controller.BaseController;
import com.isoft.entity.Tickets;
import com.isoft.service.impl.TicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("sys/tickets")
public class TicketController extends BaseController {
    @Autowired
    TicketService ticketService;

    /**
     * 添加购票信息
     * @param tickets
     * @return
     */
    @SysControllerLogAnnotation(sysType = SysType.GENERAL,operateType = OprateType.INSERT,desc = "购票")
    @PostMapping("/add")
    public ResponseData<Boolean> addTickets(Tickets tickets){
        return returnBoolean(ticketService.addTickets(tickets));
    }
    @GetMapping("/getByUserid")
    public ResponseData<Object> selectByUsername(Integer currentPage, Integer size,Integer userid){
        return returnObject(ticketService.selectByUserid(currentPage,size,userid));
    }
    /*
    * 退票
    * */
    @SysControllerLogAnnotation(sysType = SysType.GENERAL, operateType = OprateType.UPDATE, desc = "退票")
    @PutMapping("/tuipiao")
    public ResponseData<Boolean> tuipiao(Integer id){
        return returnBoolean(ticketService.tuipiao(id));
    }
    /**
     * 查询购票信息
     * @return
     */
    @GetMapping("/show")
    public IPage<Tickets> showTickets(Integer currentPage, Integer size){
        return ticketService.showTickets(currentPage,size);
    }

}
